package com.ruoyi.shop.good.reply.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mall.common.domain.DtsReply;
import com.ruoyi.shop.good.reply.service.IDtsReplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 回复Controller
 *
 * @author ruoyi
 * @date 2025-03-13
 */
@RestController
@RequestMapping("/good/respond/reply")
public class DtsReplyController extends BaseController
{
    @Autowired
    private IDtsReplyService dtsReplyService;

    /**
     * 查询回复列表
     */
    @PreAuthorize("@ss.hasPermi('respond:reply:list')")
    @GetMapping("/list")
    public TableDataInfo list(DtsReply dtsReply)
    {
        startPage();
        List<DtsReply> list = dtsReplyService.selectDtsReplyList(dtsReply);
        return getDataTable(list);
    }

    /**
     * 导出回复列表
     */
    @PreAuthorize("@ss.hasPermi('respond:reply:export')")
    @Log(title = "回复", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DtsReply dtsReply)
    {
        List<DtsReply> list = dtsReplyService.selectDtsReplyList(dtsReply);
        ExcelUtil<DtsReply> util = new ExcelUtil<DtsReply>(DtsReply.class);
        util.exportExcel(response, list, "回复数据");
    }

    /**
     * 获取回复详细信息
     */
    @PreAuthorize("@ss.hasPermi('respond:reply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dtsReplyService.selectDtsReplyById(id));
    }

    /**
     * 新增回复
     */
    @PreAuthorize("@ss.hasPermi('respond:reply:add')")
    @Log(title = "回复", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DtsReply dtsReply)
    {
        return toAjax(dtsReplyService.insertDtsReply(dtsReply));
    }

    /**
     * 修改回复
     */
    @PreAuthorize("@ss.hasPermi('respond:reply:edit')")
    @Log(title = "回复", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DtsReply dtsReply)
    {
        return toAjax(dtsReplyService.updateDtsReply(dtsReply));
    }

    /**
     * 删除回复
     */
    @PreAuthorize("@ss.hasPermi('respond:reply:remove')")
    @Log(title = "回复", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dtsReplyService.deleteDtsReplyByIds(ids));
    }
}
